import Vue from 'vue'
import Router from 'vue-router'

import Layout from '@/components/layout'
import Home from '@/pages/home/index.vue'

import companyRoutes from './modules/company'
import personalRoutes from './modules/personal'

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      component: Layout,
      redirect: '/home',
      children: [
        {
          path: '/:role/:type/password/change',
          name: '密码管理',
          component: () => import(/* webpackChunkName: "company" */ '../pages/password/change.vue'),
          meta: {
            title: '密码管理',
            owner: '/password/change'
          }
        },
        ...companyRoutes,
        ...personalRoutes,
      ]
    }, {
      path: '/:role/auth/:type',
      name: '登录',
      component: () => import(/* webpackChunkName: "company" */ '../pages/login/index.vue')
    }, {
      path: '/login',
      name: '登录跳板',
      redirect: '/home'
      // component: () => import(/* webpackChunkName: "company" */ '../pages/login/index.vue')
    }, {
      path: '/register',
      name: '注册跳板',
      component: () => import(/* webpackChunkName: "company" */ '../pages/login/register.vue')
    }, {
      path: '/protocol',
      name: '协议',
      component: () => import(/* webpackChunkName: "company" */ '../pages/protocol/index.vue')
    }, {
      path: '/personal/check',
      name: '认证授权',
      component: () => import(/* webpackChunkName: "company" */ '../pages/personal/steps/index.vue')
    }, {
      path: '/home',
      name: '首页',
      component: () => import(/* webpackChunkName: "company" */ '../pages/home/index.vue')
    }
  ]
})
